<?php

require_once("configuration.php");
require_once("includes/function.php");

$quantity = isset($_POST['quantity']) ? $_POST['quantity'] : NULL;
$submit = isset($_POST['submit']) ? $_POST['submit'] : NULL;

if($submit == "Checkout")
{
    $mysql->c();
    header("HTTP/1.1 301 Moved Permanently");
    header("location: cart.checkout.php");
    exit();
}
if (is_array($quantity) && count($quantity) > 0) {
    require_once("includes/cart.php");
    $cart = new customers_cart();
    $cart->session_id = $CurrentSession->session_id;
    $cart->status = cart_status::Active;
    
    foreach($quantity as $product_id => $value)
    {
        $cart->product_id = $product_id;
        $cart->quantity = $value;
        $cart->update();
    }
    
    $mysql->c();
    header("HTTP/1.1 301 Moved Permanently");
    header("location: cart.edit.php");
    exit();
}
require_once("configuration.end.php");
?>